home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / dist-packages / AppInstall / Util.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-10-12  |  3.0 KB  |  87 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import os
  5. import os.path as os
  6. import apt_pkg
  7. (COL_CAT_NAME, COL_CAT_ITEM) = range(0, 2)
  8. (COL_NAME, COL_ITEM, COL_POPCON) = range(3)
  9.  
  10. def get_maintenance_end_date(release_date, m_months):
  11.     '''
  12.     get the (year, month) tuple when the maintenance for the distribution
  13.     ends
  14.     '''
  15.     years = m_months / 12
  16.     months = m_months % 12
  17.     support_end_year = release_date.year + years + (release_date.month + months) / 12
  18.     support_end_month = (release_date.month + months) % 12
  19.     return (support_end_year, support_end_month)
  20.  
  21.  
  22. def get_release_date_from_release_file(path):
  23.     '''
  24.     return the release date as time_t for the given release file
  25.     '''
  26.     if not path or not os.path.exists(path):
  27.         return None
  28.     tag = apt_pkg.ParseTagFile(open(path))
  29.     tag.Step()
  30.     if not tag.Section.has_key('Date'):
  31.         return None
  32.     date = tag.Section['Date']
  33.     return apt_pkg.StrToTime(date)
  34.  
  35.  
  36. def get_release_filename_for_pkg(cache, pkgname, label, release):
  37.     ''' get the release file that provides this pkg '''
  38.     if not cache.has_key(pkgname):
  39.         return None
  40.     pkg = cache[pkgname]
  41.     ver = None
  42.     for aver in pkg._pkg.VersionList:
  43.         if aver == None or aver.FileList == None:
  44.             continue
  45.         
  46.         for verFile, index in aver.FileList:
  47.             if verFile.Origin == label and verFile.Label == label and verFile.Archive == release:
  48.                 ver = aver
  49.                 continue
  50.         
  51.     
  52.     if not ver:
  53.         return None
  54.     indexfile = cache._list.FindIndex(ver.FileList[0][0])
  55.     for metaindex in cache._list.List:
  56.         for m in metaindex.IndexFiles:
  57.             if indexfile and indexfile.Describe == m.Describe and indexfile.IsTrusted:
  58.                 dir = apt_pkg.Config.FindDir('Dir::State::lists')
  59.                 name = apt_pkg.URItoFileName(metaindex.URI) + 'dists_%s_Release' % metaindex.Dist
  60.                 return dir + name
  61.         
  62.     
  63.  
  64.  
  65. def xmlescape(s):
  66.     escape = escape
  67.     import xml.sax.saxutils
  68.     if s == None:
  69.         return ''
  70.     return escape(s)
  71.  
  72.  
  73. def iterate_list_store(store, it):
  74.     ''' iterate over a gtk tree-model, returns a gtk.TreeIter for each element
  75.     '''
  76.     if not it:
  77.         raise StopIteration
  78.     it
  79.     yield it
  80.     while True:
  81.         it = store.iter_next(it)
  82.         if it == None:
  83.             raise StopIteration
  84.         it == None
  85.         yield it
  86.  
  87.